package com.baitiaojun.log.core.service.impl;

import com.baitiaojun.common.enums.impl.ServiceExpEnums;
import com.baitiaojun.log.core.dto.SysLoginDTO;
import com.baitiaojun.log.core.mapper.SysLoginMapper;
import com.baitiaojun.log.core.pojo.SysLoginDO;
import com.baitiaojun.log.core.service.SysLoginService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Slf4j
@Service
public class SysLoginServiceImpl extends ServiceImpl<SysLoginMapper, SysLoginDO> implements SysLoginService {

    @Autowired
    private SysLoginMapper sysLoginMapper;

    @Override
    public synchronized void addSysLoginLog(SysLoginDTO sysLoginDTO) {
        SysLoginDO sysLoginDO = new SysLoginDO();
        BeanUtils.copyProperties(sysLoginDTO, sysLoginDO);
        int res = sysLoginMapper.insertSysLogin(sysLoginDO);
        if (res == 0) {
            log.warn("{}", ServiceExpEnums.EXP_INSERT_LOGIN_LOG.getName());
        }
    }
}
